Next | Prev | Up | Top | Contents | Index
Configuring for a Dynamic Major Number
You can place a hyphen ("-") in the third field of the descriptive line; that is, the field for the major device number (see "Descriptive Line"). When the line also contains the b or c flag, indicating a device driver, a hyphen in the third field means that lboot is to assign some unused major device number dynamically when the module is registered.
Since a device driver can only be called by opening a device special file, and since a device special file has to be defined based on a major device number, how can the device special files be created?
The assigned major number can be discovered using the ml command. The command
ml list -r
writes a list of all registered modules, including their major numbers. The following procedure can be used to make the assignment of the major device number completely dynamic.
- Make the device driver loadable, specifying the d, R, and D flags.
- Specify a hyphen for the major number.
- In the driver, get the major number dynamically, if indeed the driver needs to know its major number at all.
- In a script executed from rc2.d (just as the /dev/MAKEDEV script is executed), call ml to list registered drivers.
- Parse the output of ml using UNIX utilities to extract the major device number from the line describing your driver.
- Execute mknod or install commands to create special device files using the discovered major number.
Next | Prev | Up | Top | Contents | Index